package com.jh.paymentchannel.repository;

import com.jh.paymentchannel.pojo.MiLianQuickRegister;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface MiLianQuickRegisterRepository extends JpaRepository<MiLianQuickRegister, String>, JpaSpecificationExecutor<MiLianQuickRegister> {

    @Query("select ml from  MiLianQuickRegister ml where ml.userId=:userId and ml.bankCard=:bankCard")
    public MiLianQuickRegister getMiLianQuickRegisterByUseridAndBankCard(@Param("userId") long userId, @Param("bankCard") String bankCard);

    @Query("select ml from  MiLianQuickRegister ml where ml.userId=:userId")
    public MiLianQuickRegister getMiLianQuickRegisterByUserid(@Param("userId") long userId);

    @Modifying
    @Query("delete from MiLianQuickRegister ml where ml.userId=:userId and ml.bankCard=:bankCard")
    public Integer deleteMiLianRegisterByUIdAndBankId(@Param("userId") long userId, @Param("bankCard") String bankCard);

    @Modifying
    @Query("update MiLianQuickRegister ml set ml.state='Y' where ml.userId=:userId and ml.bankCard=:bankCard")
    public Integer updateMiLianRegisterStateByUIdAndBankId(@Param("userId") long userId, @Param("bankCard") String bankCard);
}
